import java.util.ArrayList;
import java.util.List;
import java.util.Random;
public class CardDemo {
   private final String[] suits = {"♥", "♣","♠","♦"};

   public List<Card> buyCard(){
       List<Card> list=new ArrayList<>();
       for(int i=0;i<4;i++){
           for (int j=0;j<13;j++){
               Card card=new Card(suits[i],j);
               list.add(card);
           }
       }
       return list;
   }
   //洗牌
   public void shuffle(List<Card> list){
       Random ran=new Random();
       for(int i=list.size()-1;i>0;i--){
           int index=ran.nextInt(i);
           Card tmp=list.get(i);
           list.set(i,list.get(index));
           list.set(index,tmp);
       }
   }
   //揭牌轮流拿5张
   public void getCard(List<Card> list){
       List<Card> hand1=new ArrayList<>();
       List<Card> hand2=new ArrayList<>();
       List<Card> hand3=new ArrayList<>();
       List<List<Card>> hands=new ArrayList<>();
       hands.add(hand1);
       hands.add(hand2);
       hands.add(hand3);
    for(int i=0;i<5;i++){
        for(int j=0;j<3;j++){
            Card card=list.remove(0);
            hands.get(j).add(card);
        }
    }
       System.out.println("第一个人揭牌：");
       System.out.println(hand1);
       System.out.println("第二个人揭牌：");
       System.out.println(hand2);
       System.out.println("第三个人揭牌：");
       System.out.println(hand3);
       System.out.println("剩下的牌：");
       System.out.println(list);





   }

}
